/**
  ******************************************************************************
  * @file    tasks_common.h
  * @author  Iron
  * @date    2018-09-25
  * @version v1.0
  * @brief   template header file
  */

#ifndef _TASKS_COMMON_H
#define _TASKS_COMMON_H

#ifdef __cplusplus
extern "C" {
#endif

/* includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "event_groups.h"

/* exported types ------------------------------------------------------------*/
/* exported constants --------------------------------------------------------*/
/* exported macro ------------------------------------------------------------*/
#if configMAX_PRIORITIES <= 8
#error "configMAX_PRIORITIES must > 8"
#endif

// configMAX_PRIORITIES 10
#define TASK_PRIORITY_BASE            (( UBaseType_t) 5)

#define TASK_PRIORITY_REALTIME        (( UBaseType_t )(TASK_PRIORITY_NORMAL + 3))    // 8
#define TASK_PRIORITY_HIGHT           (( UBaseType_t )(TASK_PRIORITY_NORMAL + 2))    // 7
#define TASK_PRIORITY_ABOVE_NORMAL    (( UBaseType_t )(TASK_PRIORITY_NORMAL + 1))    // 6
#define TASK_PRIORITY_NORMAL          (  TASK_PRIORITY_BASE  )                       // 5
#define TASK_PRIORITY_BELOW_NORMAL    (( UBaseType_t )(TASK_PRIORITY_NORMAL - 1))    // 4
#define TASK_PRIORITY_LOW             (( UBaseType_t )(TASK_PRIORITY_NORMAL - 2))    // 3
#define TASK_PRIORITY_IDLE            (  tskIDLE_PRIORITY    )                       // 2

/* application priority config */
#define APP_TASK_PRI_CLI                 TASK_PRIORITY_BELOW_NORMAL   // 4：CLI command
#define SYS_TASK_PRI_SYSTEM              TASK_PRIORITY_LOW            // 3: watchdog clear task, > 1600ms MAX823L RESET, > 4096ms IWG RESET
#define SYS_TASK_PRI_LWIP                TASK_PRIORITY_LOW
#define SYS_TASK_PRI_LWIP_SLIP           TASK_PRIORITY_LOW
#define SYS_TASK_PRI_LWIP_DEFAULT        TASK_PRIORITY_LOW

#define APP_TASK_PRI_SNTP                TASK_PRIORITY_NORMAL         // 5: sntp sync rtc time
#define APP_TASK_PRI_MONITOR             TASK_PRIORITY_NORMAL         // 5: device monitor thread

// used for test
#define APP_TASK_PRI_TEST                TASK_PRIORITY_LOW
#define APP_TASK_PRI_TCP_TEST            TASK_PRIORITY_LOW

/* exported functions ------------------------------------------------------- */
/* task cli */
void task_cli_start(void);

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* _TASKS_COMMON_H */

/******************* (C)COPYRIGHT 2018 ***** END OF FILE *********************/
